/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import bean.*;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.http.HttpSession;
import Model.*;
import org.apache.catalina.Session;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
 *
 * @author cpn02
 */
public class BuyAction extends Action {

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {




        
        Customer cus = (Customer) request.getSession().getAttribute("customer");
        ArrayList<CartBean> carts  = (ArrayList<CartBean>)request.getSession().getAttribute("carts");
        ProModel.buy(cus, carts);
        carts.clear();
        return mapping.findForward("success");
    }

}
